home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
UTILITY1
/
MSWSRC35.ZIP
/
DLGWIND.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-14
|
56KB
|
2,195 lines
#include "allwind.h"
#define TWindow_type 1
#define TStatic_type 2
#define TListBox_type 3
#define TComboBox_type 4
#define TButton_type 5
#define TScrollBar_type 6
#define TGroupBox_type 7
#define TRadioButton_type 8
#define TCheckBox_type 9
#define TDialog_type 10
//NODE *xxx;
HICON hCursorSave = 0; /* handle for saved cursor */
char *Windowname[]={"?","Window","Static","ListBox","ComboBox","Button","ScrollBar","GroupBox","RadioButton","CheckButton","Dialog"};
char mainwindow[]="ROOT";
/* class structure for storing information about users windows */
class slink
{
friend class slist;
slink *next;
slink *prev;
char *key;
char *parent;
int type;
ent e;
slink(ent a, slink* n, slink* p, char *k, char *par, int t)
{
e=a;
next=n;
prev=p;
key=k;
parent=par;
type=t;
}
};
class slist
{
slink* last;
public:
void insert(ent a, char* k, char* par, int t);
ent get(char* k);
ent get2(char* k, int t);
char *getparent(char* par);
void zap(char* k);
void list(char* k, int lev);
void clear();
slist()
{
last = NULL;
}
slist(ent a, char *k, char *par, int t)
{
last=new slink(a, NULL, NULL, k, par, t);
last->next=last;
last->prev=last;
}
~slist()
{
clear();
}
};
void slist::insert(ent a, char* k, char *par, int t)
{
if (last)
{
last->next = new slink(a, last->next, last, k, par, t);
last->next->next->prev = last->next;
}
else
{
last = new slink(a, NULL, NULL, k, par, t);
last->next = last;
last->prev = last;
}
}
ent slist::get2(char *k,int t)
{
slink* f;
if (last==NULL) return NULL;
f = last;
do
{
if (strcmp(f->key,k)==0)
{
if (f->type == t) return(f->e); else return(NULL);
}
f = f->next;
} while (f != last);
return NULL;
}
ent slist::get(char *k)
{
slink* f;
if (last==NULL) return NULL;
f = last;
do
{
if (strcmp(f->key,k)==0)
{
return(f->e);
}
f = f->next;
} while (f != last);
return NULL;
}
char *slist::getparent(char *k)
{
slink* f;
if (last==NULL) return NULL;
f = last;
do
{
if (strcmp(f->parent,k)==0)
{
return(f->key);
}
f = f->next;
} while (f != last);
return NULL;
}
void slist::zap(char* k)
{
slink* f;
slink* p;
char* t;
if (last==NULL) return;
f = last;
p = NULL;
do
{
if (strcmp(f->key,k)==0)
{
p = f;
break;
}
f = f->next;
} while (f != last);
// delete any children first
while ((t=getparent(k)) != NULL) { zap(t); }
if (p != NULL)
{
f = p->next;
if (f == p)
{
last = NULL;
}
else
{
if (p == last) last = p->prev;
p->prev->next = p->next;
f->prev = p->prev;
}
delete p;
}
}
void slist::list(char *k,int level)
{
slink* f;
slink* ff;
slink* p;
char temp[128];
char indent[128];
int i;
if (last==NULL) return;
f = last;
p = NULL;
do
{
if (strcmp(f->key,k)==0)
{
p = f;
break;
}
f = f->next;
} while (f != last);
if (p != NULL)
{
indent[0] = '\0';
for (i=0;i<level;i++) strcat(indent," ");
if (level == 0)
{
sprintf(temp,"%s %s",Windowname[p->type],p->key);
putcombobox(temp);
}
ff = last;
do
{
if (strcmp(ff->parent,k)==0)
{
sprintf(temp," %s%s %s",indent,Windowname[ff->type],ff->key);
putcombobox(temp);
list(ff->key,level+1);
}
ff = ff->next;
} while (ff != last);
}
}
void slist::clear()
{
slink* l = last;
if (l == NULL) return;
do
{
slink* ll = l;
l = l->next;
delete ll;
}
while (l!=last);
}
// class structures for the controls we support, for the most part they
// are the same as the original with just a key and callback string added
class TMxWindow : public TWindow
{
public:
char key[MAX_BUFFER_SIZE];
TMxWindow(PTWindowsObject AParent, LPSTR AText, PTModule AModule = NULL) :
(AParent, AText, AModule) {};
};
class TMxDialog : public TDialog
{
public:
char key[MAX_BUFFER_SIZE];
char callback[MAX_BUFFER_SIZE];
char caption[MAX_BUFFER_SIZE];
int x,y,h,w;
TMxDialog(PTWindowsObject AParent, LPSTR AText, PTModule AModule = NULL) :
(AParent, AText, AModule) {};
virtual void SetupWindow();
};
void TMxDialog::SetupWindow()
{
SetWindowPos(HWindow, NULL, x, y, w, h, 0);
SetCaption(caption);
do_execution(callback);
TDialog::SetupWindow();
}
class TMyListBox : public TListBox
{
public:
char key[MAX_BUFFER_SIZE];
TMyListBox(PTWindowsObject AParent, int AnId, int X, int Y,
int W, int H, PTModule AModule = NULL) :
(AParent, AnId, X, Y, W, H, AModule) {};
};
class TMxComboBox : public TComboBox
{
public:
char key[MAX_BUFFER_SIZE];
TMxComboBox(PTWindowsObject AParent, int AnId, int X, int Y,
int W, int H, DWORD AStyle, WORD ATextLen, PTModule AModule = NULL) :
(AParent, AnId, X, Y, W, H, AStyle, ATextLen, AModule) {};
};
class TMyStatic : public TStatic
{
public:
char key[MAX_BUFFER_SIZE];
TMyStatic(PTWindowsObject AParent, int AnId, LPSTR AText, int X, int Y,
int W, int H, WORD ATextLen, PTModule AModule = NULL) :
(AParent, AnId, AText, X, Y, W, H, ATextLen, AModule) {};
};
class TMyButton : public TButton
{
public:
char key[MAX_BUFFER_SIZE];
char callback[MAX_BUFFER_SIZE];
// NODE *callbackx;
int critical;
TMyButton(PTWindowsObject AParent, int AnId, LPSTR AText, int X, int Y,
int W, int H, BOOL IsDefault, PTModule AModule = NULL) :
(AParent, AnId, AText, X, Y, W, H, IsDefault, AModule) {};
virtual void DefWndProc(RTMessage Msg);
};
NODE *leventcheck(void)
{
MSG msg;
// checkqueue();
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (UNBOUND);
}
/* function that processes our own queued events */
void checkqueue()
{
callthing *thing;
int save_yield_flag;
int sv_val_status;
while (thing=calllists.get())
{
sv_val_status = val_status;
calllists.zap();
switch (thing->kind)
{
// mouse event must not yield while processing
case 1:
{
save_yield_flag = yield_flag;
yield_flag = 0;
mouse_posx = thing->arg1;
mouse_posy = thing->arg2;
do_execution(thing->func);
yield_flag = save_yield_flag;
break;
}
// keyboard event must not yield while processing
case 2:
{
save_yield_flag = yield_flag;
yield_flag = 0;
keyboard_value = thing->arg1;
do_execution(thing->func);
yield_flag = save_yield_flag;
break;
}
// Button, timer or other event ok to yield while processing
case 3:
{
do_execution(thing->func);
break;